package com.laogao.controller;

import com.laogao.po.SysDictData;
import com.laogao.service.ISysDictDataService;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
/**
 * 第20课：通用实体类字典字段填充工具
 * <b>description</b>： Java进阶、性能优化实战案例100讲，微信公众号:程序员恰恰，源码 & 文档 & 技术支持，请加个人微信号：it3306 <br>
 * <b>time</b>：2025/3/8 21:27 <br>
 * <b>author</b>：ready lao_gao
 */
@RestController
@RequestMapping("/dict/data")
public class SysDictDataController {
    @Resource
    private ISysDictDataService dictDataService;

    @GetMapping("/list")
    public List<SysDictData> list() {
        return dictDataService.list();
    }

    @PostMapping
    public boolean save(@RequestBody SysDictData dictData) {
        return dictDataService.saveOrUpdate(dictData);
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable Long id) {
        return dictDataService.removeById(id);
    }
}